package com.iflytek.ci.cpms.dao;

import com.iflytek.ci.cpms.domain.Milestone;
import com.iflytek.framework.mybatis.extra.MyBatisDao;
import com.iflytek.framework.pagination.PaginationCriteria;
import com.iflytek.framework.pagination.PaginationResult;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * milestone db interface
 * </p>
 * 
 * @author mdzhang
 * 
 */
@MyBatisDao
public interface MilestoneDao {

	/**
	 * add a new Milestone
	 * 
	 * @param milestone
	 */
	int add_new_milestone(Milestone milestone);

	/**
	 * edit milestone
	 * 
	 * @param milestone
	 */
	int update_milestone(Milestone milestone);

	/**
	 * select milestone by milestone_id
	 * 
	 * @param milestone_id
	 * @return milestone
	 */
	Milestone find_milestone_with_id(long milestone_id);

	/**
	 * Advanced query for milestone
	 * select milestone with many condition like 
	 */
	List<Milestone> get_milestone_with(long projectId,Map<String,Object> params);
	
	/**
	 * select milestone with project_id
	 * 
	 * @param p_id
	 * @return
	 */
	List<Milestone> find_milestone_project(long p_id);

	/**
	 * remove a milestone
	 * 
	 * @param milestone_id
	 */
	int remove_milestone_id(long milestone_id);

	/**
	 * remove project's milestone
	 * 
	 * @param project_id
	 */
	int remove_milestone_pid(long project_id);
    
	/**
	 * 分页获取所有里程碑
	 * @param criteria
	 * @return
	 */
	PaginationResult<Milestone> page_all_milestone(PaginationCriteria criteria);
	
	/**
	 * 分页获取某项目所有里程碑
	 * @param criteria
	 * @return
	 */
	PaginationResult<Milestone>page_pro_milestone(PaginationCriteria criteria,long project_id);
	
	/**
	 * 删除多个milestone
	 * @param ids
	 *           多个里程碑的id
	 */
	int remove_milestone(long[] ids);
	
	/**
	 * 删除多个项目的里程碑信息
	 * @param p_ids
	 */
	int delete_with_pids(String[] p_ids);

    int  get_issue_number_with_milestone(long m_id);
    
    /**
     * 判断里程碑是否存在反馈信息，返回值不为0代表有，为0代表全部没有
     * @param ids
     *     多个milestone的id
     * @return
     */
    Milestone get_issue_top(long[]ids);

    /**
     * 增加某里程碑的反馈信息数量
     * @param milestone_id
     *     里程碑的id
     * @param num
     *      添加的反馈信息数量
     */
    int update_counts(long milestone_id,int num);
    
    /**
     * 里程碑的反馈信息数量减1
     * @param milestone
     */
    int reduce_counts(long milestone);
    
    /**
     * 添加里程碑完成描述
     * @param description
     * @param milestone_id
     */
    int update_finish(String description,long milestone_id);
    
    /**
     * 获取里程碑的全部反馈信息数量
     * @param milestone_id
     *     里程碑id
     * @return
     *    反馈信息总是
     */
    int count_all_milestone(long milestone_id);
    
    /**
     * 获取里程碑所有的关闭的反馈信息数
     * @param milestone_id
     *     里程碑id
     * @return
     *    关闭的反馈信息数
     */
    int count_close_milestone(long milestone_id);
    
    /**
     * 获取所有里程碑的信息
     * @return
     */
    List<Milestone> all_milestone();
    
    /**
     * 更新cate_count值
     * @param cate_count
     * @param milestone_id
     */
    int update_cate_count(String cate_count,long milestone_id);
}
